openmp-fix-runtimes-build
authorLLVM Packaging Team <pkg-llvm-team@lists.alioth.debian.org>
Tue, 16 Dec 2025 11:47:30 +0000 (12:47 +0100)
committerSylvestre Ledru <sylvestre@debian.org>
Tue, 16 Dec 2025 11:47:30 +0000 (12:47 +0100)
include required runtimes as dependencies to openmp targets to make sure
they are built first when included as part of a runtimes build since openmp
can depend on them

Gbp-Pq: Name openmp-fix-runtimes-build.diff

llvm/runtimes/CMakeLists.txt
offload/libomptarget/CMakeLists.txt
offload/plugins-nextgen/cuda/CMakeLists.txt
offload/plugins-nextgen/host/CMakeLists.txt
openmp/CMakeLists.txt
openmp/runtime/CMakeLists.txt
openmp/runtime/src/CMakeLists.txt
openmp/tools/archer/CMakeLists.txt

index 94a43b96d218802d363c552d8b2dadc6ec3e6607..3f9210b6f1c7a44f57e6b03195fd13f3a89d88a8 100644 (file)
@@ -270,6 +270,7 @@ function(runtime_default_target)
                                       -DLLVM_ENABLE_PROJECTS_USED=${LLVM_ENABLE_PROJECTS_USED}
                                       -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=${LLVM_ENABLE_PER_TARGET_RUNTIME_DIR}
                                       -DLLVM_BUILD_TOOLS=${LLVM_BUILD_TOOLS}
+                                      -DCMAKE_SYSTEM_PROCESSOR=${CMAKE_SYSTEM_PROCESSOR}
                                       -DCMAKE_C_COMPILER_WORKS=ON
                                       -DCMAKE_CXX_COMPILER_WORKS=ON
                                       -DCMAKE_Fortran_COMPILER_WORKS=ON
@@ -636,7 +637,7 @@ if(build_runtimes)
     # build directory cannot find the C++ headers in certain configurations.
     # I need to build a mechanism for runtime projects to provide CMake code
     # that executes at LLVM configuration time to handle this case.
-    add_dependencies(clang-bootstrap-deps runtimes-configure)
+    #add_dependencies(clang-bootstrap-deps runtimes-configure)
     # We need to add the runtimes as a dependency because compiler-rt can be
     # built as part of runtimes and we need the profile runtime for PGO
     add_dependencies(clang-bootstrap-deps runtimes)
index 93e684e53bf1723e8343f96e9d7a581b6281769d..eef10022c869ec2537a65dec0bdc0cbf6b691733 100644 (file)
@@ -40,6 +40,9 @@ add_llvm_library(omptarget
   NO_INSTALL_RPATH
   BUILDTREE_ONLY
 )
+
+add_runtimes_build_depends_if_needed(omptarget)
+
 target_include_directories(omptarget PRIVATE
   ${LIBOMPTARGET_INCLUDE_DIR} ${LIBOMPTARGET_BINARY_INCLUDE_DIR}
 )
index 5fdfb8f9cf6282490637a3d3c57fef2bc09d7c23..d5837983b5ac331621d768d37676950384b4d061 100644 (file)
@@ -26,3 +26,5 @@ else()
   message(STATUS "Not generating NVIDIA tests, no supported devices detected."
                    " Use 'LIBOMPTARGET_FORCE_NVIDIA_TESTS' to override.")
 endif()
+
+add_runtimes_build_depends_if_needed(omptarget.rtl.cuda)
index d5126b34a956305e75cf91f2684a9a51928af1ef..e465e746327323922a8997d2a49bd3d5a8db33f6 100644 (file)
@@ -27,6 +27,8 @@ else()
   target_include_directories(omptarget.rtl.host PRIVATE dynamic_ffi)
 endif()
 
+add_runtimes_build_depends_if_needed("omptarget.rtl.${machine}")
+
 target_include_directories(omptarget.rtl.host PRIVATE
                            ${LIBOMPTARGET_INCLUDE_DIR})
 
index c206386fa6b614ffcba85c8a019d49219b28fab8..cf9f98195eab7f2ad1153d7d3948f54e9d38980b 100644 (file)
@@ -122,6 +122,28 @@ else()
   get_clang_resource_dir(LIBOMP_HEADERS_INSTALL_PATH SUBDIR include)
 endif()
 
+option(OPENMP_USE_LLVM_UNWINDER "Build and use the LLVM unwinder" OFF)
+
+option(LIBOMP_ENABLE_RTTI "Enabling RTTI forces libomp to be a c++ lib" ${LLVM_ENABLE_RTTI})
+
+macro(add_runtimes_build_depends_if_needed target)
+  if(RUNTIMES_BUILD)
+    # required for rtti and libomp/libomptarget profiling if enabled
+    add_dependencies(${target} cxx-headers cxxabi_static cxx_static cxxabi_shared cxx_shared)
+    if(OPENMP_USE_LLVM_UNWINDER AND (NOT target STREQUAL "omp" AND NOT LIBOMP_ENABLE_RTTI))
+      add_dependencies(${target} unwind_static unwind_shared)
+      get_target_property(target_link_flags ${target} LINK_FLAGS)
+      set(runtimes_link_flags "-lunwind")
+      if(target_link_flags)
+        set(runtimes_link_flags "${target_link_flags} -lunwind")
+      endif()
+      set_target_properties(${target}
+        PROPERTIES
+        LINK_FLAGS "${runtimes_link_flags}")
+    endif()
+  endif()
+endmacro()
+
 # Build host runtime library, after LIBOMPTARGET variables are set since they are needed
 # to enable time profiling support in the OpenMP runtime.
 add_subdirectory(runtime)
index a0cffe7b5c94be53fe46eab69819a5c063d81666..e4f81ab46c9af6eb11ea42c2c4b9454c4848eb1b 100644 (file)
@@ -336,6 +336,10 @@ if(LIBOMP_STATS)
   set(LIBOMP_USE_STDCPPLIB TRUE)
 endif()
 
+if(LIBOMP_ENABLE_RTTI)
+  set(LIBOMP_USE_STDCPPLIB TRUE)
+endif()
+
 # Shared library can be switched to a static library
 set(LIBOMP_ENABLE_SHARED TRUE CACHE BOOL
   "Shared library instead of static library?")
index 698e185d9c4dde6ebc52965bed7537fb4e05b57d..b18f787478196371e11cc4478302d615589f3b93 100644 (file)
@@ -157,6 +157,7 @@ set_source_files_properties(${LIBOMP_ASMFILES} ${LIBOMP_GNUASMFILES} PROPERTIES
 if(NOT ${LIBOMP_USE_STDCPPLIB})
   set(LIBOMP_LINKER_LANGUAGE C)
   set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES)
+  set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++")
 else()
   set(LIBOMP_LINKER_LANGUAGE CXX)
 endif()
@@ -235,6 +236,8 @@ else()
   )
 endif()
 
+add_runtimes_build_depends_if_needed(omp)
+
 # Get the library's location within the build tree for the unit tester
 if(NOT WIN32)
   get_target_property(LIBOMP_LIBRARY_DIR omp LIBRARY_OUTPUT_DIRECTORY)
index 980eb2b0b675fb904f3645de19adba1070eee4e2..9f018f7f72703a3884ed88be501e179cf5e9d399 100644 (file)
@@ -15,6 +15,9 @@ if(LIBOMP_OMPT_SUPPORT AND LIBOMP_ARCHER_SUPPORT)
   target_link_libraries(archer ${CMAKE_DL_LIBS})
   add_library(archer_static STATIC ompt-tsan.cpp)
 
+  add_runtimes_build_depends_if_needed(archer)
+  add_runtimes_build_depends_if_needed(archer_static)
+
   install(TARGETS archer archer_static
     LIBRARY DESTINATION ${OPENMP_INSTALL_LIBDIR}
     ARCHIVE DESTINATION ${OPENMP_INSTALL_LIBDIR})